from tgasdk import TGAnalytics, LoggingConsumer, ROTATE_MODE, BatchConsumer
import datetime
class Test:
    batchConsumer = BatchConsumer(server_uri="http://129.211.113.36:10010/", appid="test_2217",
                                  compress=True)
    ta = TGAnalytics(batchConsumer)

    def report_platform_account_login_event(self,distinct_id, account_id, created_at, last_login_time):
        properties = {
            u'created_at': None,
            u'last_login_time': None
        }
        self.ta.track(distinct_id=distinct_id, account_id=account_id, event_name='platform_account_login',
                    properties=properties)
        self.ta.flush()
        # 更新用户最后一次登陆时间
        self.ta.user_set(distinct_id=distinct_id, account_id=account_id, properties={"last_login_time": last_login_time})

if __name__ == '__main__':
    test = Test()
    test.report_platform_account_login_event(distinct_id=None,account_id=23655958,created_at=datetime.datetime.now(),last_login_time=datetime.datetime.now())